package com.example.exporttemplate.controller;

import com.example.exporttemplate.service.WordChartService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * 文件导出控制器
 *
 * @author liulindong
 * @version 2022/7/3 10:31
 */
@RestController
@RequestMapping(value = "/export")
public class FileExportController {

    private final WordChartService wordChartService;

    public FileExportController(WordChartService wordChartService) {
        this.wordChartService = wordChartService;
    }


    /**
     * 导出word图表（柱状图+折线图）
     * @param response http响应
     */
    @GetMapping("/word_export_with_bar_and_line")
    public void wordExportWithBarAndLine(HttpServletResponse response) {
        wordChartService.wordExportWithBarAndLine(response);
    }



    /**
     * 导出饼图
     * @param response http响应
     */
    @GetMapping("/pieChart")
    public void exportPie(HttpServletRequest request, HttpServletResponse response) {
        wordChartService.exportPie(request, response);
    }



    /**
     * 读取模板文件，打印文件信息
     *
     * @param response http响应
     */
    @GetMapping("/word_histogram_by_copy_template")
    public void wordHistogramByCopyTemplate(HttpServletResponse response) {
        wordChartService.wordHistogramByCopyTemplate(response);
    }


    /**
     * 手动绘制散点图
     */
    @GetMapping("/word_histogram_by_draw")
    public void wordHistogramByDraw(HttpServletResponse response) {
        wordChartService.wordHistogramByDraw(response);
    }


    /**
     * 导出课程评价报告（OBE）
     * @param response http响应
     */
    @GetMapping("/word_course_report")
    public void wordCourseReport(HttpServletResponse response) {
        wordChartService.exportCourseReport(response);
    }


    /**
     * 测试生成目录(功能暂不可用)
     * @param response http响应
     */
    @GetMapping("/test_word_catalogue")
    public void wordCatalogue(HttpServletResponse response) {
        wordChartService.wordCatalogue(response);
    }


    /**
     * 读取模板的方式，生成目录，并可以自动更新域
     * @param response http响应
     */
    @GetMapping("readTemplateCreateTOC")
    public void readTemplateCreateTOC(HttpServletResponse response) {
        wordChartService.readTemplateCreateTOC(response);
    }


    /**
     * word生成圆环图
     * @param response http响应
     */
    @GetMapping("createDoughnutChart")
    public void createDoughnutChart(HttpServletResponse response) {
        wordChartService.createDoughnutChart(response);
    }


    /**
     * 测试word表格内单元格换行
     * @param response http响应
     */
    @GetMapping("test_tablecell_nextline")
    public void testTableCellNextLine(HttpServletResponse response) {
        wordChartService.testTableCellNextLine(response);
    }


    @GetMapping("/picture")
    public void exportPicture(HttpServletResponse response) {
        wordChartService.exportPicture(response);
    }


    @GetMapping("/rich_text_word")
    public void exportRichTextWord(HttpServletResponse response) {
        wordChartService.exportRichTextWord(response);
    }


    /**
     * 通过POIFSFileSystem方式导出富文本内容
     */
    @GetMapping("/export_by_poisystem")
    public void exportByPOISystem(HttpServletResponse response) {
        wordChartService.exportByPOISystem(response);
    }


    /**
     * 通过hutool导出word
     */
    @GetMapping("/export_by_hutool")
    public void doc2docx(HttpServletResponse response) {
        wordChartService.exportByHutool(response);
    }


    /**
     * 通过Aspose.words导出富文本word
     *
     * @param response http响应
     */
    @GetMapping("/export_by_aspose")
    public void exportByAspose(HttpServletResponse response) {
        wordChartService.exportByAspose(response);
    }


    /**
     * 导出表格
     * @param response 响应
     */
    @GetMapping("/table")
    public void exportTable(HttpServletResponse response) {
        wordChartService.wordExport(response);
    }
}
